<template>
	<view>
		<view class="body">
			<view class="">
				<uni-forms :value="formData" ref="form" :rules="rules">

					<uni-group>

						<uni-forms-item required label="家庭人口数" name="pops" labelWidth="120">
							<uni-easyinput type="number" v-model="formData.pops"></uni-easyinput>
						</uni-forms-item>

						<uni-forms-item required label="家庭成员在学人数" name="learns" labelWidth="120">
							<uni-easyinput type="number" v-model="formData.learns"></uni-easyinput>
						</uni-forms-item>

						<uni-forms-item required label="赡养人口数" name="support" labelWidth="120">
							<uni-easyinput placeholder="年龄70岁以上为赡养人口" type="number" v-model="formData.support">
							</uni-easyinput>
						</uni-forms-item>

						<uni-forms-item required label="家庭成员失业人数" name="nojob" labelWidth="120">
							<uni-easyinput type="number" v-model="formData.nojob"></uni-easyinput>
						</uni-forms-item>
						<text style="color: #F43559;font-size: 15px;">填写了失业人数的请提供失业证复印件</text>


					</uni-group>


					<uni-group>
						<uni-forms-item labelWidth="100" name="type" label="困难类型(多选)">
							<uni-data-checkbox multiple mode="list" v-model="formData.type" :localdata="type">
							</uni-data-checkbox>
						</uni-forms-item>
						<text style="color: #F43559;font-size: 15px;">以上选项都是有登记造册的，请提交相应材料的复印件</text>
					</uni-group>

					<uni-group>

						<uni-forms-item labelWidth="100" label="健康状况" name="hea">

							<uni-data-checkbox multiple v-model="formData.hea" :localdata="healthy"
								@change="disability_dis()"></uni-data-checkbox>
						</uni-forms-item>


						<uni-forms-item v-if="hea_dis" name="disability" labelWidth="100" label=" ">
							<uni-data-checkbox v-model="formData.disability" :localdata="disability">
							</uni-data-checkbox>
						</uni-forms-item>


						<uni-forms-item v-if="hea_dis" labelWidth="100" label=" " name="disability_level">
							<uni-data-checkbox v-model="formData.disability_level" :localdata="disability_level">
							</uni-data-checkbox>
						</uni-forms-item>



						 <uni-forms-item labelWidth="100" label=" " name="diseases">
							<uni-data-checkbox multiple v-model="formData.diseases" :localdata="healthy2"
								@change="diseases_dis()"></uni-data-checkbox>
						</uni-forms-item>

						<uni-forms-item labelWidth="100" label=" " name="disea_name">
							<uni-easyinput :disabled="disea_dis" v-model="formData.disea_name" placeholder="所患疾病名称">
							</uni-easyinput>
						</uni-forms-item>
						<text style="color: #F43559;font-size: 15px;">该项需提供填写了本人残疾证复印件、重大疾病证明</text>

					</uni-group>


					<!-- 提交 -->
					<uni-group>
						<button type="primary" @click="submit">下一页(2/5)</button>
					</uni-group>

				</uni-forms>


			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hea_dis: false,
				disea_dis: true,

				formData: {
					learns: '',
					pops: '',
					support: '',
					nojob: '',
					type: [],
					jb: [],
					hea:[],
					disability:[],
					disability_level:[],
					diseases:[],
					disea_name:''
					
					
				},

				type: [{
						text: '建档立卡户',
						value: 0
					}, {
						text: '特困供养人员',
						value: 1
					}, {
						text: '城乡最低生活保障户(低保证)',
						value: 2
					},
					{
						text: '特困职工子女',
						value: 3
					},
					{
						text: '低收入家庭成员(低收入证)',
						value: 4
					},
					{
						text: '孤儿',
						value: 5
					},
					{
						text: '父母不能履行抚养义务的儿童',
						value: 6
					}, {
						text: '父母一方抚养',
						value: 7
					},
					{
						text: '享受国家定期抚恤补助的优抚对象子女',
						value: 8
					},
					{
						text: '因公牺牲警察子女',
						value: 9
					}
				],
				healthy: [{
					text: '本人残疾',
					value: 0
				}],
				healthy2: [{
					text: '学生本人患重大疾病',
					value: 0
				}],
				disability: [{
						text: '视力残疾',
						value: 0
					},
					{
						text: '听力残疾',
						value: 1
					},
					{
						text: '智力残疾',
						value: 2
					},
					{
						text: '其它残疾',
						value: 3
					}
				],
				disability_level: [{
						text: '一级残疾',
						value: 0
					},
					{
						text: '二级残疾',
						value: 1
					},
					{
						text: '三级残疾',
						value: 2
					},
					{
						text: '四级残疾',
						value: 3
					}
				],
				rules: {


					learns: {
						rules: [{
								required: true,
								errorMessage: '请输入在学人数'
							},
							{

							}
						]
					},
					pops: {
						rules: [{
							required: true,
							errorMessage: '请输入家庭人口数'
						}]
					},
					support: {
						rules: [{
							required: true,
							errorMessage: '请输入赡养人口数'
						}]
					},
					nojob: {
						rules: [{
							required: true,
							errorMessage: '请输入家庭成员失业人数'
						}]
					}

				}

			}
		},
		onLoad: function() {

			uni.showLoading({
				title: '加载中'
			})
			uni.getStorage({
				key: 'kunnan_info',
				success: (res) => {
					getApp().globalData.kunnan = res.data
					console.log(res.data.jbqk)
					if (res.data.jbqk != undefined) {
						this.formData = res.data.jbqk
						if (res.data.jbqk.hea.length != 0) {
							this.hea_dis = true
						}
						if (res.data.jbqk.diseases.length != 0) {
							this.disea_dis = false
						}
					}

					setTimeout(function() {
						uni.hideLoading();
					}, 300);
				},
				fail: () => {
					setTimeout(function() {
						uni.hideLoading();
					}, 300);
				}
			})
		},
		methods: {
			submit() {
				this.$refs.form.submit().then(res => {
					console.log('表单数据信息：', res);
					getApp().globalData.kunnan.jbqk = res
					uni.setStorage({
						key: 'kunnan_info',
						data: getApp().globalData.kunnan
					})
					uni.navigateTo({
						url: 'familyInfo'
					})
				}).catch(err => {
					console.log('表单错误信息：', err);
				})
			},
			disability_dis() {
				this.hea_dis = !this.hea_dis;

			},
			diseases_dis() {
				this.disea_dis = !this.disea_dis;
			}
		}
	}
</script>

<style>

</style>
